home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3.iso
/
chapte22
/
ex5.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-27
|
3KB
|
66 lines
#include <genstub.c>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static BOOL bAnsi = TRUE;
switch (uMsg)
{
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
{
int iResult;
TCHAR szBuffer[128];
HDC hDC = GetDC( hWnd );
// ANSI string of accented characters to translate,
// Similar string without accented characters
static TCHAR szAccentedChars[] = { 0xe1, 0xe2,
0xe7, 0xe8,
0xed, 0xec, 0
};
static TCHAR szUnaccentedChars[] = "aaCeii";
// lstrcmp fails
TextOut( hDC, 0, 0, szBuffer, wsprintf(szBuffer,
"Result of lstrcmp of %s vs %s: %d",
szAccentedChars, szUnaccentedChars,
lstrcmp( szAccentedChars, szUnaccentedChars ) ) );
// lstrcmpi fails because it only ignores case.
TextOut( hDC, 0, 20, szBuffer, wsprintf(szBuffer,
"Result of lstrcmpi of %s vs %s: %d",
szAccentedChars, szUnaccentedChars,
lstrcmpi( szAccentedChars, szUnaccentedChars ) ) );
// do CompareStrings in French - it works
iResult = CompareString( MAKELCID(0x40C, SORT_DEFAULT),
NORM_IGNORECASE |
NORM_IGNORENONSPACE |
NORM_IGNOREWIDTH,
szAccentedChars, 6,
szUnaccentedChars, 6 );
// We must subtract 2 bias from result to make it
// look like strcmp.
TextOut( hDC, 0, 40, szBuffer, wsprintf(szBuffer,
"Result of CompareStrings of %s vs %s: %d",
szAccentedChars, szUnaccentedChars, iResult-2 ) );
ReleaseDC( hWnd, hDC );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
}
return( NULL );
}